var path = require("path");
var express = require("express");
var app = express();
app.use(express.static("static"));
var cookieParser = require("cookie-parser");
app.use(cookieParser());
var expressSession = require("express-session");
app.use(expressSession({
    secret: "suijishuzi",
    resave: false,
    saveUninitialized: true
}))
app.use(cookieParser());
//连接数据库
var mongoose = require("mongoose");
mongoose.connect("127.0.0.1/blog");
var exphbs = require("express-handlebars");
app.set("views", path.join(__dirname, "views"));
app.engine(".hbs", exphbs({
    layoutsDir: "views/layouts",
    defaultLayout: "main",
    extname: ".hbs"
}));
app.set("view engine", ".hbs");
var routerMain = require("./router/main");
app.use("/", routerMain);

app.listen(8888);
console.log("开始启动8888端口");